home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mntdoc01.zoo / mintdoc / cat2 / psigaction.nr < prev    next >
Encoding:
Text File  |  1993-03-03  |  5.7 KB  |  199 lines

  1.  
  2.  
  3.  
  4. Psigaction(2)              May 1, 1992              Psigaction(2)
  5.  
  6.  
  7. N✓NA✓AM✓ME✓E
  8.        Psigaction - change the way a signal is handled
  9.  
  10. S✓SY✓YN✓NO✓OP✓PS✓SI✓IS✓S
  11.        #include <signal.h>
  12.  
  13.        LONG Psigaction(WORD sig, struct sigaction *act, struct sigaction *oact);
  14.  
  15. D✓DE✓ES✓SC✓CR✓RI✓IP✓PT✓TI✓IO✓ON✓N
  16.        _✓P_✓s_✓i_✓g_✓a_✓c_✓t_✓i_✓o_✓n changes the handling of the signal indicated by
  17.        _✓s_✓i_✓g (which must be between 1 and  31;  symbolic  constants
  18.        for symbols are defined in the file signal.h).
  19.  
  20.  
  21.        If  _✓a_✓c_✓t  is  non-zero,  then  it  is assumed to point to a
  22.        structure describing the signal  handling  behavior.  This
  23.        structure has the following members:
  24.        struct sigaction {
  25.             LONG sa_handler;
  26.             LONG sa_mask;
  27.             WORD sa_flags;
  28.        }
  29.        If  _✓s_✓a_✓__✓h_✓a_✓n_✓d_✓l_✓e_✓r is SIG_DFL, then the default action for the
  30.        signal will occur when the signal is delivered to the pro-
  31.        cess.
  32.  
  33.  
  34.        If  _✓s_✓a_✓__✓h_✓a_✓n_✓d_✓l_✓e_✓r is SIG_IGN, then the signal will be ignored
  35.        by the process, and delivery of the signal  will  have  no
  36.        noticeable  effect  (in  particular,  the  signal will not
  37.        interrupt the _✓P_✓a_✓u_✓s_✓e or _✓P_✓s_✓i_✓g_✓p_✓a_✓u_✓s_✓e system calls,  q.v.).  If
  38.        the  signal is pending at the time of the _✓P_✓s_✓i_✓g_✓n_✓a_✓l call, it
  39.        is discarded.
  40.  
  41.  
  42.        If _✓s_✓a_✓__✓h_✓a_✓n_✓d_✓l_✓e_✓r is some other value, it is assumed to be the
  43.        address  of  a  user function that will be called when the
  44.        signal is delivered to the process. The user  function  is
  45.        called  with a single LONG argument on the stack, which is
  46.        the number of the signal being delivered (this is done  so
  47.        that  processes  may  use the same handler for a number of
  48.        different signals). While the signal is being handled,  it
  49.        is  blocked from delivery; thus, signal handling is "reli-
  50.        able" (unlike Version 7 and early System V Unix  implemen-
  51.        tations, in which delivery of a second signal while it was
  52.        being handled could kill the process).  The set of signals
  53.        specified  in _✓s_✓a_✓__✓m_✓a_✓s_✓k are also blocked from delivery while
  54.        the signal handler is executing.   Note  that,  unlike  in
  55.        some versions of Unix, the signal handling is not reset to
  56.        the default  action  before  the  handler  is  called;  it
  57.        remains set to the given signal handler.
  58.  
  59.  
  60.        The  signal handler must either return (via a normal 680x0
  61.  
  62.  
  63.  
  64. Version 0.95         MiNT Programmer's Manual                   1
  65.  
  66.  
  67.  
  68.  
  69.  
  70. Psigaction(2)              May 1, 1992              Psigaction(2)
  71.  
  72.  
  73.        rts instruction) or call the  _✓P_✓s_✓i_✓g_✓r_✓e_✓t_✓u_✓r_✓n  system  call  to
  74.        indicate  when signal handling is complete; in both cases,
  75.        the signal will be  unblocked.  Psigreturn  also  performs
  76.        some  internal clean-up of the kernel stack that is neces-
  77.        sary if the signal handler is not planning to return  (for
  78.        example, if the C longjmp() function is to be used to con-
  79.        tinue execution at another point in the program).
  80.  
  81.  
  82.        Signal handlers may make any GEMDOS, BIOS, or XBIOS system
  83.        calls freely.  GEM AES and VDI calls should not be made in
  84.        a signal handler.
  85.  
  86.  
  87.        The _✓s_✓a_✓__✓f_✓l_✓a_✓g_✓s field specifies  additional,  signal-specific
  88.        signal  handling  behavior.   If  _✓s_✓i_✓g  is SIGCHLD, and the
  89.        _✓S_✓A_✓__✓N_✓O_✓C_✓L_✓D_✓S_✓T_✓O_✓P bit is set in _✓s_✓a_✓__✓f_✓l_✓a_✓g_✓s, then the SIGCHLD sig-
  90.        nal  is sent to this process only when one of its children
  91.        terminates (and not when a child is  suspended  by  a  job
  92.        control signal).
  93.  
  94.  
  95.        The  _✓o_✓a_✓c_✓t argument to _✓P_✓s_✓i_✓g_✓a_✓c_✓t_✓i_✓o_✓n, if non-zero, specifies a
  96.        structure that will be set to reflect the signal  handling
  97.        for  _✓s_✓i_✓g  that  was  current at the time of the _✓P_✓s_✓i_✓g_✓a_✓c_✓t_✓i_✓o_✓n
  98.        system call.
  99.  
  100.  
  101.        Note that calling _✓P_✓s_✓i_✓g_✓a_✓c_✓t_✓i_✓o_✓n to change behavior of a  sig-
  102.        nal  has the side effect of unmasking that signal, so that
  103.        delivery is possible. This is done so that processes  may,
  104.        while handling a signal, reset the behavior and send them-
  105.        selves another instance of  the  signal,  for  example  in
  106.        order  to  suspend themselves while handling a job control
  107.        signal.  Signal handling is  preserved  across  _✓P_✓f_✓o_✓r_✓k  and
  108.        _✓P_✓v_✓f_✓o_✓r_✓k  calls.  Signals that are ignored by the parent are
  109.        also ignored by the child after a _✓P_✓e_✓x_✓e_✓c call; signals that
  110.        were  being caught for handling in a function are reset in
  111.        the child to the default behavior.
  112.  
  113.  
  114. R✓RE✓ET✓TU✓UR✓RN✓NS✓S
  115.        0 on success
  116.  
  117.  
  118.        ERANGE if _✓s_✓i_✓g is not a legal signal.
  119.  
  120.  
  121.        EACCDN if the signal may not be caught by the user
  122.  
  123.  
  124. S✓SE✓EE✓E A✓AL✓LS✓SO✓O
  125.        _✓P_✓k_✓i_✓l_✓l(2), _✓P_✓s_✓i_✓g_✓b_✓l_✓o_✓c_✓k(2), _✓P_✓s_✓i_✓g_✓n_✓a_✓l(2), _✓P_✓s_✓i_✓g_✓r_✓e_✓t_✓u_✓r_✓n(2)
  126.  
  127.  
  128.  
  129.  
  130. Version 0.95         MiNT Programmer's Manual                   2
  131.  
  132.  
  133.  
  134.  
  135.  
  136. Psigaction(2)              May 1, 1992              Psigaction(2)
  137.  
  138.  
  139. B✓BU✓UG✓GS✓S
  140.        Signal handling can be nested only a small (around 3) num-
  141.        ber  of  times,  i.e. if 4 signals are delivered to a pro-
  142.        cess, and the process has established handlers for all  4,
  143.        and  none  of  the handlers has returned or called _✓P_✓s_✓i_✓g_✓r_✓e_✓-
  144.        _✓t_✓u_✓r_✓n,
  145.         then there is a very good  chance  of  a  stack  overflow
  146.        killing  the process off. In practice, this is unlikely to
  147.        happen.
  148.  
  149.  
  150. A✓AU✓UT✓TH✓HO✓OR✓R
  151.        Alex Kiernan
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196. Version 0.95         MiNT Programmer's Manual                   3
  197.  
  198.  
  199.